package drds.server.util.cmd;

import java.util.HashMap;
import java.util.Map;

/**
 * -host=192.168.1.1:8080 -
 * 
 * 
 * 
 */
public class CmdArgs {
	private static final CmdArgs cmdArgs = new CmdArgs();

	private Map<String, String> map;

	private CmdArgs() {
		map = new HashMap<String, String>();
	}

	public static CmdArgs getInstance(String[] args) {
		Map<String, String> map = CmdArgs.cmdArgs.map;
		for (int i = 0, length = args.length; i < length; i++) {
			String arg = args[i].trim();
			int split = arg.indexOf('=');
			map.put(arg.substring(1, split), arg.substring(split + 1));
		}
		return CmdArgs.cmdArgs;
	}

	public String getString(String name) {
		return map.get(name);
	}

	public int getInt(String name) {
		return Integer.parseInt(getString(name));
	}

	public long getLong(String name) {
		return Long.parseLong(getString(name));
	}

	public boolean getBoolean(String name) {
		return Boolean.parseBoolean(getString(name));
	}
}
